package com.pac.questionnaire.dao.impl;

import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.pac.questionnaire.bean.QuestionOptionBean;
import com.pac.questionnaire.dao.QuestionOptionDao;

/**
 * 问题选项dao实现
 * 
 * @author lujun.chen
 * @version [版本号, 2015年2月24日]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@Repository(value = "questionOptionDao")
public class QuestionOptionDaoImpl implements QuestionOptionDao {

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	@Override
	public String addQuestionOption(QuestionOptionBean questionOptionBean) {
		sqlSessionTemplate.insert("addQuestionOption", questionOptionBean);
		return questionOptionBean.getId();
	}

	@Override
	public boolean updateQuestionOption(QuestionOptionBean questionOptionBean) {
		int n = sqlSessionTemplate.update("updateQuestionOption",
				questionOptionBean);
		return n > 0;
	}

	@Override
	public boolean delQuestionOption(QuestionOptionBean questionOptionBean) {
		int n = sqlSessionTemplate.delete("delQuestionOption",
				questionOptionBean);
		return n > 0;
	}

	@Override
	public List<QuestionOptionBean> queryQuestionOption(
			QuestionOptionBean questionOptionBean) {
		return sqlSessionTemplate.selectList("queryQuestionOption",
				questionOptionBean);
	}

}
